#include <iostream>
#include <fstream>
#include <string>
#include <sstream>

static const int size = 200;
static const double alpha = 0.1;
int main(int argc, char *argv[])
{

	double temp[size][size];

	for (int i = 0; i < size; ++i)
	{
		for (int j = 0; j < size; ++j)
		{
			temp[i][j] = 0;
		}
	}

	double charTemp = 0.0;
	for (int k = 1; k < size-1; ++k)
	{
		std::ostringstream fileName;
		fileName << "data." << k;
		charTemp += 1.0;
		temp[size/2][size/2] += charTemp;
		for (int i = 1; i < size-1; ++i)
		{
			for (int j = 1; j < size-1; ++j)
			{
				temp[i][j] = alpha * temp[i][j] + (1 - alpha)*0.25
						*(temp[i-1][j] + temp[i+1][j] + temp[i][j-1]
								+ temp[i][j+1]);
			}
		}
		charTemp = temp[size/2][size/2];
		std::ofstream outFile(fileName.str().c_str());
		for (int i = 0; i < size; ++i)
		{
			for (int j = 0; j < size; ++j)
			{
				outFile << i << " " << j << " " << temp[i][j] << '\n';
			}
			outFile << '\n';
		}
	}

	return 0;
}
